const { DataTypes } = require('sequelize');
const { sequelizeTarget } = require('../../utils/db');
const {generateUUIDId} = require("../../utils/generatId");



const AuthInfo = sequelizeTarget.define('Auth', {
    id: {
        type: DataTypes.STRING(255),
        primaryKey: true,
        defaultValue: () => generateUUIDId(),
    },
    username: {
        type: DataTypes.STRING(255),
        allowNull: false,
        unique: true,
    },

    password: {
        type: DataTypes.STRING(255),
        allowNull: true,
    },
    MD5: {
        type: DataTypes.STRING(255),
        allowNull: true,
    },
}, {
    tableName: 'Auth',
    timestamps: true,
});


// 同步模型到数据库
AuthInfo.sync()
    .then(() => {
        console.log('用户模型映射完成');
    })

    .catch((error) => {
        console.error('Error creating table:', error);
    });

module.exports = AuthInfo;
